package com.cyl.manager.ums.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import com.cyl.manager.ums.convert.MemberH5LogConvert;
import com.cyl.manager.ums.domain.MemberH5Log;
import com.cyl.manager.ums.pojo.query.MemberH5LogQuery;
import com.cyl.manager.ums.service.MemberH5LogService;
import com.cyl.manager.ums.pojo.vo.MemberH5LogVO;
import com.ruoyi.common.utils.poi.ExcelUtil;
/**
 * H5会员日志采集Controller
 *
 * @author zcc
 * @date 2025-03-24
 */
@Api(description ="H5会员日志采集接口列表")
@RestController
@RequestMapping("/ums/memberH5Log")
public class MemberH5LogController extends BaseController {
    @Autowired
    private MemberH5LogService service;
    @Autowired
    private MemberH5LogConvert convert;

    @ApiOperation("查询H5会员日志采集列表")
    @PreAuthorize("@ss.hasPermi('ums:memberH5Log:list')")
    @PostMapping("/list")
    public ResponseEntity<Page<MemberH5Log>> list(@RequestBody MemberH5LogQuery query, Pageable page) {
        List<MemberH5Log> list = service.selectList(query, page);
        return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
    }

    @ApiOperation("导出H5会员日志采集列表")
    @PreAuthorize("@ss.hasPermi('ums:memberH5Log:export')")
    @Log(title = "H5会员日志采集", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public ResponseEntity<String> export(MemberH5LogQuery query) {
        List<MemberH5Log> list = service.selectList(query, null);
        ExcelUtil<MemberH5LogVO> util = new ExcelUtil<>(MemberH5LogVO.class);
        return ResponseEntity.ok(util.writeExcel(convert.dos2vos(list), "H5会员日志采集数据"));
    }

    @ApiOperation("获取H5会员日志采集详细信息")
    @PreAuthorize("@ss.hasPermi('ums:memberH5Log:query')")
    @GetMapping(value = "/{id}")
    public ResponseEntity<MemberH5Log> getInfo(@PathVariable("id") Long id) {
        return ResponseEntity.ok(service.selectById(id));
    }

    @ApiOperation("新增H5会员日志采集")
    @PreAuthorize("@ss.hasPermi('ums:memberH5Log:add')")
    @Log(title = "H5会员日志采集", businessType = BusinessType.INSERT)
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody MemberH5Log memberH5Log) {
        return ResponseEntity.ok(service.insert(memberH5Log));
    }

    @ApiOperation("修改H5会员日志采集")
    @PreAuthorize("@ss.hasPermi('ums:memberH5Log:edit')")
    @Log(title = "H5会员日志采集", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResponseEntity<Integer> edit(@RequestBody MemberH5Log memberH5Log) {
        return ResponseEntity.ok(service.update(memberH5Log));
    }

    @ApiOperation("删除H5会员日志采集")
    @PreAuthorize("@ss.hasPermi('ums:memberH5Log:remove')")
    @Log(title = "H5会员日志采集", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResponseEntity<Integer> remove(@PathVariable Long[] ids) {
        return ResponseEntity.ok(service.deleteByIds(ids));
    }
}
